/*
*/

#include <search.h>
#include <beam.h>
#include <display.h>
#include <event.h>
#include <keypad.h>
#include <timer.h>

static u32 Press(u32 evn){
    u32	key;

    switch(key=GetKey(evn)){
    case KEY___TV:
    case KEY_CABL:
    case KEY__DVD:
    case KEY__AUX:
	info.page=key-KEY___TV;
	IndicatorOn();
	return MOD_NIL;
    }
    do evn=WaitEvent();
    while(evn!=EVN_KEYRELEASE);
    return MOD_SEARCH;
}

u32 Search(u32 stt){
    u32	evn,t_m;

    FlashAll();
    t_m=Timer();
    while(stt==MOD_SEARCH){
	evn=WaitEvent();
	if((evn&EVN_MASK)==EVN_KEYPRESS){
	    stt=Press(evn);
	    t_m=Timer();
	}
	if(TimeOut(t_m,TIM_OUT)){
	    stt=MOD_NIL;
	    IndicatorOff();
	}
    }
    return stt;
}
